import {useMemo,useState} from 'react'
import { useAppSelector } from '../app/hooks'
export function useCar(){
  const shopCarList = useAppSelector(state => state.shopcarReducer.ShopCarList)

  const totalCount = shopCarList.reduce((p,n) => {
    return p + n.count
  },0)
  const totalCheckedPrice = shopCarList.reduce((p,n) => {
    return n.checked?p+n.count * n.price:p
  },0)
  const isAllChecked = shopCarList.every(v => v.checked)
  
  return {totalCount,totalCheckedPrice,isAllChecked}
}